<HTML><HEAD>
<!--
    --------------------------------
    UTILITIES: Fun with Date Formats
    --------------------------------
-->

<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers

/*
    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
    Copyright (C)1998 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 
*/

//------------------STRING-ARRAY UTILITY-------------------

// Find the substring at index n, counting 0 to n
function doIndex(aString, n)
{
    
    var str=""+aString
    
    // Count until the correct index
    for(var i = 0; i < n; i++)
    {
        var where = str.indexOf(':', 1)
        str = str.substring(where+1, str.length)
    }

    // Lop off the end of the string
    return str.substring(0, str.indexOf(':'))
}

// --------------------DATE STRING UTILITIES---------------------

// Return the 3-letter symbol for month #n
function month(n)
{
    var m = "Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec:"
    return doIndex(m, n)
}

// Return the name of month #n
function fullMonth(n)
{
    var m = "January:February:March:April:May:June:July:"+
            "August:September:October:November:December:"
    return doIndex(m, n)
}


// Return the 3-letter symbol for day #n
function day(n)
{
    var d = "Sun:Mon:Tue:Wed:Thu:Fri:Sat:"
    return doIndex(d, n)
}

// Return the name of day #n
function fullDay(n)
{
    var d = 
        "Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday:Sunday:"
    return doIndex(d, n)
}

// --------------------ANNOTATION UTILITIES---------------------

function comment(aString)
{
    document.write("<FONT SIZE=4 COLOR='007777'><b>")
    document.write(aString)
    document.write("</b></FONT><br>")
}

function observe(aString)
{
    document.write("<FONT SIZE=3 COLOR='000000'>")
    document.write(aString)
    document.write("</FONT><BR>")
}

function show(aString)
{
    document.write("<FONT SIZE=4 COLOR='770000'>")
    document.write(aString)
    document.write("</FONT><br>")
}

<!-- done hiding --></SCRIPT></HEAD>

<BODY bgcolor="ffffff" link="0000ff" vlink="770077">

<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
    ALIGN = LEFT>Date Formats</H1></FONT>
<BLOCKQUOTE>
<FONT COLOR="770000">
  This script helps you format your dates in a variety of ways. These
  function, which convert month and date numbers into strings,
  each use the function <FONT COLOR="007777">doIndex()</FONT>
   which addresses a string as if it were an array.
</FONT></BLOCKQUOTE>

<FONT SIZE=4>
<SCRIPT>
    var d = new Date()

    comment('Format: MM/DD/YY')
    observe("(d.getMonth()+1)+'/'+d.getDate()+'/'+d.getYear()")
    show('<dd>The date is '+
        (d.getMonth()+1)+'/'+d.getDate()+'/'+d.getYear())
    document.write('<p>')

    comment('Format: DD MON YY')
    observe("d.getDate()+' '+month(d.getMonth())+' '+d.getYear()")
    show('<dd>The date is '+
        d.getDate()+' '+month(d.getMonth())+' '+d.getYear())
    document.write('<p>')

    comment('Format: DD, Month, YYYY')
    observe("d.getDate()+' '+fullMonth(d.getMonth())+', 19'+d.getYear()")
    show('<dd>The date is '+
        d.getDate()+' '+fullMonth(d.getMonth())+', 19'+d.getYear())
    document.write('<p>')

    comment('Format: Month DD, YYYY')
    observe("d.getMonth())+' '+d.getDate()+', 19'+d.getYear()")
    show('<dd>The date is '+
        fullMonth(d.getMonth())+' '+d.getDate()+', 19'+d.getYear())
    document.write('<p>')

    comment('Format: DDD, Month, DD, YYYY')
    observe("day(d.getDay())+', '+fullMonth(d.getMonth())+"+
            "' '+d.getDate()+', 19'+d.getYear()")
    show('<dd>The date is '+
        day(d.getDay())+', '+fullMonth(d.getMonth())+
        ' '+d.getDate()+', 19'+d.getYear())
    document.write('<p>')

    comment('Format: Day, Month, DD, YYYY')
    observe("fullDay(d.getDay())+', '+fullMonth(d.getMonth())+"+
            "' '+d.getDate()+', 19'+d.getYear()")
    show('<dd>The date is '+
        fullDay(d.getDay())+', '+fullMonth(d.getMonth())+
        ' '+d.getDate()+', 19'+d.getYear())
    document.write('<p>')
    
    document.write("<br><br>")
    comment("DATE STRING UTILITIES")

</SCRIPT></FONT>



<PRE><FONT COLOR="770000" SIZE=3>
//------------------STRING-ARRAY UTILITY-------------------

// Find the substring at index n, counting 0 to n
function doIndex(aString, n)
{
    
    var str=""+aString
    
    // Count until the correct index
    for(var i = 0; i < n; i++)
    {
        var where = str.indexOf(':', 1)
        str = str.substring(where+1, str.length)
    }

    // Lop off the end of the string
    return str.substring(0, str.indexOf(':'))
}

// --------------------DATE STRING UTILITIES---------------------

// Return the 3-letter symbol for month #n
function month(n)
{
    var m = "Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec:"
    return doIndex(m, n)
}
</FONT></PRE>
    
<h5>Copyright &copy;1998 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>